//
//  DailyCollectionCell.m
//  花花时尚
//
//  Created by 霍文轩 on 15/8/25.
//  Copyright (c) 2015年 霍文轩. All rights reserved.
//

#import "DailyCollectionCell.h"
#import "ArticleModel.h"
#import "Define.h"

#import "UIImageView+WebCache.h"

@interface DailyCollectionCell ()
@end

@implementation DailyCollectionCell
-(void)dealloc{
    [_showImageView release];
    [super dealloc];
}
-(instancetype)initWithFrame:(CGRect)frame{
    self  = [super initWithFrame:frame];
    if(self){
        self.backgroundColor = [UIColor darkGrayColor];
        self.showImageView = [[ShowImageView alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height) model:nil];
        _showImageView.userInteractionEnabled = NO; // 直接点击cell，所以不需要imageView的响应
        [self.contentView addSubview:_showImageView];
        [_showImageView release];
    }
    return self;
}
-(void)setCellWithModel:(ArticleModel *)model{
    _showImageView.model = model;
    _showImageView.label.text = model.title;
    _showImageView.label.frame = CGRectMake(0, self.frame.size.height-30, self.frame.size.width, 30); // 需要重复设定label的frame，防止从重用池取出后导致位置错乱
    
    _showImageView.label.text = model.title;
    _showImageView.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);
    NSDictionary * simgDic = [model.simgs objectAtIndex:0]; // 取得simg数组的唯一一个元素，储存图片的信息
    NSString * urlString = [NSString stringWithFormat:@"%@%@",kWebImageDomain,[simgDic objectForKeyedSubscript:@"url"]];
    [_showImageView sd_setImageWithURL:[NSURL URLWithString:urlString]];
}

@end
